package cn.tedu.tnt_sky.controller.admin;

import cn.tedu.tnt_sky.common.result.PageResult;
import cn.tedu.tnt_sky.common.result.Result;
import cn.tedu.tnt_sky.pojo.dto.FeedbacksListPageDTO;
import cn.tedu.tnt_sky.pojo.dto.FeedbacksStatusDTO;
import cn.tedu.tnt_sky.service.FeedbacksService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/tnt/admin/feedbacks")
@Api(tags = "反馈管理")
public class FeedbacksController {

    @Autowired
    FeedbacksService feedbacksService;

    /**
     * 分页反馈列表
     * @param feedbacksListPageDTO
     * @return
     */
    @ApiOperation(value = "反馈列表")
    @GetMapping("/page")
    public Result getFeedbackList(FeedbacksListPageDTO feedbacksListPageDTO){
        log.info("查询反馈列表:{}", feedbacksListPageDTO);
        PageResult feedbackList =feedbacksService.getFeedbacksList(feedbacksListPageDTO) ;
        log.info("查询结果:{}",feedbackList);
        return Result.success(feedbackList);
    }

    @ApiOperation(value = "反馈状态管理")
    @PutMapping("/update")
    public Result updateFeedback(@RequestBody FeedbacksStatusDTO feedbacksStatusDTO){
        log.info("反馈状态：{}",feedbacksStatusDTO);
        feedbacksService.updateFeedbackStatus(feedbacksStatusDTO);
        return Result.success();
    }

    @ApiOperation(value = "反馈删除")
    @DeleteMapping("/delete/{id}")
    public Result deleteFeedback(@PathVariable long id){
        log.info("删除反馈:{}",id);
        feedbacksService.deleteFeedback(id);
        return Result.success();
    }
}
